//
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2010
// by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using Telerik.Web.UI;
namespace DotNetNuke.UI.Skins.Controls
{
	public partial class LeftMenu : UI.Skins.SkinObjectBase
	{
		private Queue PagesQueue;
		private ArrayList AuthPages;
		private ArrayList arrayShowPath;
		private string dnnSkinSrc;
		private string dnnSkinPath;
		private struct qElement
		{
			public RadPanelItem radPanelItem;
			public TabInfo page;
			public int item;
		}
		private System.String _Style = string.Empty;
		private System.String _ItemCssClass = string.Empty;
		private System.String _ItemDisabledCssClass = string.Empty;
		private System.String _ItemExpandedCssClass = string.Empty;
		private System.String _ItemFocusedCssClass = string.Empty;
		private System.String _ItemClickedCssClass = string.Empty;
		private System.String _ItemImageUrl = string.Empty;
		private System.String _ItemHoveredImageUrl = string.Empty;
		private System.Web.UI.WebControls.Unit _ItemHeight = Unit.Empty;
		private System.Web.UI.WebControls.Unit _ItemWidth = Unit.Empty;
		private System.String _RootItemCssClass = string.Empty;
		private System.String _RootItemDisabledCssClass = string.Empty;
		private System.String _RootItemExpandedCssClass = string.Empty;
		private System.String _RootItemFocusedCssClass = string.Empty;
		private System.String _RootItemClickedCssClass = string.Empty;
		private System.String _RootItemImageUrl = string.Empty;
		private System.String _RootItemHoveredImageUrl = string.Empty;
		private System.Web.UI.WebControls.Unit _RootItemHeight = Unit.Empty;
		private System.Web.UI.WebControls.Unit _RootItemWidth = Unit.Empty;
		private string _SelectedPathHeaderItemCss;
		private string _SelectedPathItemCss;
		private string _SelectedPathItemImage;
		private string _SelectedPathHeaderItemImage;
		private bool _ShowPath = true;
		private bool _EnableToolTips = true;
		private bool _ImagesOnlyPanel = false;
		private bool _EnableLevelCss = false;
		private bool _EnableItemCss = false;
		private bool _EnableRootItemCss = false;
		private int _MaxLevelNumber = 10;
		private int _MaxItemNumber = 20;
		private int _MaxLevel = -1;
		private string _ShowOnlyCurrent = string.Empty;
		private bool _EnableItemId = false;
		private bool _EnablePageIcons = true;
		private bool _EnableUserMenus = true;
		private bool _EnableAdminMenus = true;
		private bool _CopyChildItemLink = false;
		private string _PagesToExclude = string.Empty;
		private Telerik.Web.UI.RadPanelBar _RadPanel1 = null;
		protected Telerik.Web.UI.RadPanelBar RadPanel1
		{
			get
			{
				if (_RadPanel1 == null)
				{
					_RadPanel1 = new Telerik.Web.UI.RadPanelBar();
					_RadPanel1.ID = "RadPanel1";
					LeftMenu1.Controls.Add(_RadPanel1);
				}
				return _RadPanel1;
			}
		}
		public bool AllowCollapseAllItems
		{
			get { return RadPanel1.AllowCollapseAllItems; }
			set { RadPanel1.AllowCollapseAllItems = value; }
		}
		public AnimationType ExpandAnimationType
		{
			get { return RadPanel1.ExpandAnimation.Type; }
			set { RadPanel1.ExpandAnimation.Type = value; }
		}
		public int ExpandAnimationDuration
		{
			get { return RadPanel1.ExpandAnimation.Duration; }
			set { RadPanel1.ExpandAnimation.Duration = value; }
		}
		public int ExpandDelay
		{
			get { return RadPanel1.ExpandDelay; }
			set { RadPanel1.ExpandDelay = value; }
		}
		public AnimationType CollapseAnimationType
		{
			get { return RadPanel1.CollapseAnimation.Type; }
			set { RadPanel1.CollapseAnimation.Type = value; }
		}
		public int CollapseAnimationDuration
		{
			get { return RadPanel1.CollapseAnimation.Duration; }
			set { RadPanel1.CollapseAnimation.Duration = value; }
		}
		public int CollapseDelay
		{
			get { return RadPanel1.CollapseDelay; }
			set { RadPanel1.CollapseDelay = value; }
		}
		public PanelBarExpandMode ExpandMode
		{
			get { return RadPanel1.ExpandMode; }
			set { RadPanel1.ExpandMode = value; }
		}
		private string _Skin = string.Empty;
		public System.String Skin
		{
			get { return _Skin; }
			set { _Skin = value; }
		}
		public bool EnableEmbeddedSkins
		{
			get { return RadPanel1.EnableEmbeddedSkins; }
			set { RadPanel1.EnableEmbeddedSkins = value; }
		}
		public bool EnableEmbeddedBaseStylesheet
		{
			get { return RadPanel1.EnableEmbeddedBaseStylesheet; }
			set { RadPanel1.EnableEmbeddedBaseStylesheet = value; }
		}
		public bool EnableEmbeddedScripts
		{
			get { return RadPanel1.EnableEmbeddedScripts; }
			set { RadPanel1.EnableEmbeddedScripts = value; }
		}
		public string Dir
		{
			get { return RadPanel1.Attributes["dir"]; }
			set { RadPanel1.Attributes["dir"] = value; }
		}
		public System.Boolean CausesValidation
		{
			get { return RadPanel1.CausesValidation; }
			set { RadPanel1.CausesValidation = value; }
		}
		public System.String OnClientContextMenu
		{
			get { return RadPanel1.OnClientContextMenu; }
			set { RadPanel1.OnClientContextMenu = value; }
		}
		public System.String OnClientMouseOver
		{
			get { return RadPanel1.OnClientMouseOver; }
			set { RadPanel1.OnClientMouseOver = value; }
		}
		public System.String OnClientMouseOut
		{
			get { return RadPanel1.OnClientMouseOut; }
			set { RadPanel1.OnClientMouseOut = value; }
		}
		public System.String OnClientItemFocus
		{
			get { return RadPanel1.OnClientItemFocus; }
			set { RadPanel1.OnClientItemFocus = value; }
		}
		public System.String OnClientItemBlur
		{
			get { return RadPanel1.OnClientItemBlur; }
			set { RadPanel1.OnClientItemBlur = value; }
		}
		public System.String OnClientItemClicking
		{
			get { return RadPanel1.OnClientItemClicking; }
			set { RadPanel1.OnClientItemClicking = value; }
		}
		public System.String OnClientItemClicked
		{
			get { return RadPanel1.OnClientItemClicked; }
			set { RadPanel1.OnClientItemClicked = value; }
		}
		public System.String OnClientItemExpand
		{
			get { return RadPanel1.OnClientItemExpand; }
			set { RadPanel1.OnClientItemExpand = value; }
		}
		public System.String OnClientItemCollapse
		{
			get { return RadPanel1.OnClientItemCollapse; }
			set { RadPanel1.OnClientItemCollapse = value; }
		}
		public System.String OnClientLoad
		{
			get { return RadPanel1.OnClientLoad; }
			set { RadPanel1.OnClientLoad = value; }
		}
		public System.String CssClass
		{
			get { return RadPanel1.CssClass; }
			set { RadPanel1.CssClass = value; }
		}
		public System.Web.UI.WebControls.Unit Height
		{
			get { return RadPanel1.Height; }
			set { RadPanel1.Height = value; }
		}
		public System.Web.UI.WebControls.Unit Width
		{
			get { return RadPanel1.Width; }
			set { RadPanel1.Width = value; }
		}
		public bool PersistStateInCookie
		{
			get { return RadPanel1.PersistStateInCookie; }
			set { RadPanel1.PersistStateInCookie = value; }
		}
		public string CookieName
		{
			get { return RadPanel1.CookieName; }
			set { RadPanel1.CookieName = value; }
		}
		public string PagesToExclude
		{
			get { return _PagesToExclude; }
			set { _PagesToExclude = value; }
		}
		public System.String ItemCssClass
		{
			get { return _ItemCssClass; }
			set { _ItemCssClass = value; }
		}
		public System.String ItemDisabledCssClass
		{
			get { return _ItemDisabledCssClass; }
			set { _ItemDisabledCssClass = value; }
		}
		public System.String ItemExpandedCssClass
		{
			get { return _ItemExpandedCssClass; }
			set { _ItemExpandedCssClass = value; }
		}
		public System.String ItemFocusedCssClass
		{
			get { return _ItemFocusedCssClass; }
			set { _ItemFocusedCssClass = value; }
		}
		public System.String ItemClickedCssClass
		{
			get { return _ItemClickedCssClass; }
			set { _ItemClickedCssClass = value; }
		}
		public System.String ItemImageUrl
		{
			get { return _ItemImageUrl; }
			set { _ItemImageUrl = value; }
		}
		public System.String ItemHoveredImageUrl
		{
			get { return _ItemHoveredImageUrl; }
			set { _ItemHoveredImageUrl = value; }
		}
		public System.Web.UI.WebControls.Unit ItemHeight
		{
			get { return _ItemHeight; }
			set { _ItemHeight = value; }
		}
		public System.Web.UI.WebControls.Unit ItemWidth
		{
			get { return _ItemWidth; }
			set { _ItemWidth = value; }
		}
		public System.String RootItemCssClass
		{
			get { return _RootItemCssClass; }
			set { _RootItemCssClass = value; }
		}
		public System.String RootItemDisabledCssClass
		{
			get { return _RootItemDisabledCssClass; }
			set { _RootItemDisabledCssClass = value; }
		}
		public System.String RootItemExpandedCssClass
		{
			get { return _RootItemExpandedCssClass; }
			set { _RootItemExpandedCssClass = value; }
		}
		public System.String RootItemFocusedCssClass
		{
			get { return _RootItemFocusedCssClass; }
			set { _RootItemFocusedCssClass = value; }
		}
		public System.String RootItemClickedCssClass
		{
			get { return _RootItemClickedCssClass; }
			set { _RootItemClickedCssClass = value; }
		}
		public System.String RootItemImageUrl
		{
			get { return _RootItemImageUrl; }
			set { _RootItemImageUrl = value; }
		}
		public System.String RootItemHoveredImageUrl
		{
			get { return _RootItemHoveredImageUrl; }
			set { _RootItemHoveredImageUrl = value; }
		}
		public System.Web.UI.WebControls.Unit RootItemHeight
		{
			get { return _RootItemHeight; }
			set { _RootItemHeight = value; }
		}
		public System.Web.UI.WebControls.Unit RootItemWidth
		{
			get { return _RootItemWidth; }
			set { _RootItemWidth = value; }
		}
		public string SelectedPathHeaderItemCss
		{
			get { return _SelectedPathHeaderItemCss; }
			set { _SelectedPathHeaderItemCss = value; }
		}
		public string SelectedPathItemCss
		{
			get { return _SelectedPathItemCss; }
			set { _SelectedPathItemCss = value; }
		}
		public string SelectedPathItemImage
		{
			get { return _SelectedPathItemImage; }
			set { _SelectedPathItemImage = value; }
		}
		public string SelectedPathHeaderItemImage
		{
			get { return _SelectedPathHeaderItemImage; }
			set { _SelectedPathHeaderItemImage = value; }
		}
		public bool EnableToolTips
		{
			get { return _EnableToolTips; }
			set { _EnableToolTips = value; }
		}
		public bool ImagesOnlyPanel
		{
			get { return _ImagesOnlyPanel; }
			set { _ImagesOnlyPanel = value; }
		}
		public bool EnableLevelCss
		{
			get { return _EnableLevelCss; }
			set { _EnableLevelCss = value; }
		}
		public bool EnableItemCss
		{
			get { return _EnableItemCss; }
			set { _EnableItemCss = value; }
		}
		public bool EnableRootItemCss
		{
			get { return _EnableRootItemCss; }
			set { _EnableRootItemCss = value; }
		}
		public int MaxLevelNumber
		{
			get { return _MaxLevelNumber; }
			set { _MaxLevelNumber = value; }
		}
		public int MaxItemNumber
		{
			get { return _MaxItemNumber; }
			set { _MaxItemNumber = value; }
		}
		public int MaxLevel
		{
			get { return _MaxLevel; }
			set { _MaxLevel = value; }
		}
		public string ShowOnlyCurrent
		{
			get { return _ShowOnlyCurrent; }
			set { _ShowOnlyCurrent = value; }
		}
		public bool EnableItemId
		{
			get { return _EnableItemId; }
			set { _EnableItemId = value; }
		}
		public bool EnablePageIcons
		{
			get { return _EnablePageIcons; }
			set { _EnablePageIcons = value; }
		}
		public bool EnableUserMenus
		{
			get { return _EnableUserMenus; }
			set { _EnableUserMenus = value; }
		}
		public bool EnableAdminMenus
		{
			get { return _EnableAdminMenus; }
			set { _EnableAdminMenus = value; }
		}
		public bool CopyChildItemLink
		{
			get { return _CopyChildItemLink; }
			set { _CopyChildItemLink = value; }
		}
		public System.Boolean ShowPath
		{
			get { return _ShowPath; }
			set { _ShowPath = value; }
		}
		public System.String Style
		{
			get { return _Style; }
			set { _Style = value; }
		}
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			dnnSkinSrc = this.PortalSettings.ActiveTab.SkinSrc.Replace('\\', '/').Replace("//", "/");
			dnnSkinPath = dnnSkinSrc.Substring(0, dnnSkinSrc.LastIndexOf('/'));
			ApplySkin();
		}
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			TabController objTabController = new TabController();
			int i;
			int iItemIndex;
			int iRootGroupId = 0;
			qElement temp;
			int StartingItemId = 0;
			AuthPages = new ArrayList();
			PagesQueue = new Queue();
			arrayShowPath = new ArrayList();
			iItemIndex = 0;
			SetPanelbarProperties();
            if (!Page.IsPostBack)
            {
                GetShowOnlyCurrent(objTabController, ref StartingItemId, ref iRootGroupId);
                int portalID = PortalSettings.ActiveTab.IsSuperTab ? -1 : PortalSettings.PortalId;
                IList<TabInfo> desktopTabs = TabController.GetTabsBySortOrder(portalID, PortalController.GetActivePortalLanguage(portalID), true);
                for (i = 0; i <= desktopTabs.Count - 1; i++)
                {
                    {
                        if ((((TabInfo) desktopTabs[i]).TabID == this.PortalSettings.ActiveTab.TabID))
                        {
                            FillShowPathArray(ref arrayShowPath, ((TabInfo) desktopTabs[i]).TabID, objTabController);
                        }
                        if ((((TabInfo) desktopTabs[i]).IsVisible && !((TabInfo) desktopTabs[i]).IsDeleted) &&
                            ((((TabInfo) desktopTabs[i]).StartDate == DateTime.MinValue &&
                              ((TabInfo) desktopTabs[i]).EndDate == DateTime.MinValue) ||
                             (((TabInfo) desktopTabs[i]).StartDate < DateTime.Now &&
                              ((TabInfo) desktopTabs[i]).EndDate > DateTime.Now) || AdminMode) &&
                            (DotNetNuke.Security.Permissions.TabPermissionController.CanViewPage(desktopTabs[i]) &&
                             !CheckToExclude(((TabInfo) desktopTabs[i]).TabName, ((TabInfo) desktopTabs[i]).TabID)))
                        {
                            temp = new qElement();
                            temp.page = (TabInfo) desktopTabs[i];
                            temp.radPanelItem = new RadPanelItem();
                            if (
                                CheckShowOnlyCurrent(((TabInfo) desktopTabs[i]).TabID,
                                                     ((TabInfo) desktopTabs[i]).ParentId, StartingItemId, iRootGroupId) &&
                                CheckPanelVisibility((TabInfo) desktopTabs[i]))
                            {
                                iItemIndex = iItemIndex + 1;
                                temp.item = iItemIndex;
                                PagesQueue.Enqueue(AuthPages.Count);
                                RadPanel1.Items.Add(temp.radPanelItem);
                            }
                            AuthPages.Add(temp);
                        }
                    }
                }
                BuildPanelbar(RadPanel1.Items);
                if ((0 == RadPanel1.Items.Count))
                {
                    RadPanel1.Visible = false;
                }
            }
		}
		private void ApplySkin()
		{
			if ((EnableEmbeddedSkins == false && !string.IsNullOrEmpty(Skin)))
			{
				string cssLink = "<link href=\"{0}/WebControlSkin/{1}/PanelBar.{1}.css\" rel=\"stylesheet\" type=\"text/css\" />";
				cssLink = string.Format(cssLink, dnnSkinPath, Skin);
				Page.Header.Controls.Add(new LiteralControl(cssLink));
				RadPanel1.Skin = Skin;
			}
		}
		private bool CheckToExclude(string tabName, Int32 tabId)
		{
			if ((PagesToExclude == string.Empty))
			{
				return false;
			}
			string[] temp = PagesToExclude.Split(new char[] { ',' });
			if (temp.Length == 0)
			{
				return false;
			}
			foreach (string item in temp)
			{
				try
				{
					if (tabId == Int32.Parse(item.Trim()))
					{
						return true;
					}
				}
				catch
				{
					if (tabName == item.Trim())
					{
						return true;
					}
				}
			}
			return false;
		}
		private void GetShowOnlyCurrent(TabController objTabController, ref int StartingItemId, ref int iRootGroupId)
		{
			StartingItemId = 0;
			iRootGroupId = 0;
			if ((ShowOnlyCurrent == string.Empty))
			{
				return;
			}
			if ((char.IsDigit(ShowOnlyCurrent.ToCharArray()[0])))
			{
				try
				{
					StartingItemId = int.Parse(ShowOnlyCurrent);
				}
				catch (Exception ex)
				{
				}
			}
			if ((ShowOnlyCurrent.StartsWith("PageItem:")))
			{
				TabInfo temptab = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId);
				if ((temptab != null))
				{
					StartingItemId = temptab.TabID;
				}
			}
			if (("RootItem" == ShowOnlyCurrent))
			{
				iRootGroupId = this.PortalSettings.ActiveTab.TabID;
				while ((((TabInfo)objTabController.GetTab(iRootGroupId, PortalSettings.PortalId, true)).ParentId != -1))
				{
					iRootGroupId = ((TabInfo)objTabController.GetTab(iRootGroupId, PortalSettings.PortalId, true)).ParentId;
				}
			}
		}
		private bool CheckShowOnlyCurrent(int tabId, int parentId, int StartingItemId, int iRootGroupId)
		{
			if ((string.Empty == ShowOnlyCurrent && parentId == -1) || ("ChildItems" == ShowOnlyCurrent && parentId == this.PortalSettings.ActiveTab.TabID) || ("CurrentItem" == ShowOnlyCurrent && tabId == this.PortalSettings.ActiveTab.TabID) || ("RootItem" == ShowOnlyCurrent && iRootGroupId == parentId) || (StartingItemId > 0 && parentId == StartingItemId))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		private bool CheckPanelVisibility(TabInfo tab)
		{
			if (!EnableAdminMenus && tab.IsSuperTab)
			{
				return false;
			}
			if (!EnableUserMenus && !tab.IsSuperTab)
			{
				return false;
			}
			return true;
		}
		private void FillShowPathArray(ref ArrayList arrayShowPath, int selectedTabID, TabController objTabController)
		{
			TabInfo tempTab = objTabController.GetTab(selectedTabID, PortalSettings.PortalId, true);
			while ((tempTab.ParentId != -1))
			{
				arrayShowPath.Add(tempTab.TabID);
				tempTab = objTabController.GetTab(tempTab.ParentId, PortalSettings.PortalId, true);
			}
			arrayShowPath.Add(tempTab.TabID);
		}
		private void CheckShowPath(int tabId, RadPanelItem panelItemToCheck, string pageName)
		{
			if ((int)arrayShowPath[0] == tabId)
			{
				panelItemToCheck.Expanded = true;
			}
			if ((arrayShowPath.Contains(tabId)))
			{
				if ((panelItemToCheck.Level > 0))
				{
					panelItemToCheck.Selected = true;
					RadPanelItem parent = (RadPanelItem)panelItemToCheck.Owner;
					while ((parent != null && parent.Items.Count > 0))
					{
						try
						{
							parent.Expanded = true;
							parent = (RadPanelItem)parent.Owner;
						}
						catch
						{
							parent = null;
						}
					}
					if (SelectedPathItemCss != string.Empty)
					{
						panelItemToCheck.CssClass = SelectedPathItemCss;
					}
					if ((SelectedPathItemImage != string.Empty))
					{
						panelItemToCheck.ImageUrl = SelectedPathItemImage.Replace("*SkinPath*", dnnSkinPath).Replace("*PageName*", pageName);
					}
				}
				else
				{
					if ((SelectedPathHeaderItemCss != string.Empty))
					{
						panelItemToCheck.CssClass = SelectedPathHeaderItemCss;
					}
					if ((SelectedPathHeaderItemImage != string.Empty))
					{
						panelItemToCheck.ImageUrl = SelectedPathHeaderItemImage.Replace("*SkinPath*", dnnSkinPath).Replace("*PageName*", pageName);
					}
				}
			}
		}
		private void SetPanelbarProperties()
		{
			if ((Style != string.Empty))
			{
				Style += "; ";
				try
				{
					foreach (string cStyle in Style.Split(';'))
					{
						if ((cStyle.Trim().Length > 0))
						{
							RadPanel1.Style.Add(cStyle.Split(':')[0], cStyle.Split(':')[1]);
						}
					}
				}
				catch
				{
				}
			}
		}
		private void SetItemProperties(RadPanelItem currentPanelItem, int iLevel, int iItem, string pageName)
		{
			string sLevel = EnableLevelCss && iLevel < MaxLevelNumber ? "Level" + iLevel.ToString() : string.Empty;
			string sItem = iItem <= MaxItemNumber && ((EnableItemCss && iLevel > 0) || (EnableRootItemCss && iLevel == 0)) ? iItem.ToString() : string.Empty;
			if ((ItemCssClass != string.Empty))
			{
				currentPanelItem.CssClass = sLevel + ItemCssClass + sItem;
			}
			if ((ItemDisabledCssClass != string.Empty))
			{
				currentPanelItem.DisabledCssClass = sLevel + ItemDisabledCssClass + sItem;
			}
			if ((ItemExpandedCssClass != string.Empty))
			{
				currentPanelItem.ExpandedCssClass = sLevel + ItemExpandedCssClass + sItem;
			}
			if ((ItemFocusedCssClass != string.Empty))
			{
				currentPanelItem.FocusedCssClass = sLevel + ItemFocusedCssClass + sItem;
			}
			if ((ItemClickedCssClass != string.Empty))
			{
				currentPanelItem.ClickedCssClass = sLevel + ItemClickedCssClass + sItem;
			}
			if ((ItemImageUrl != string.Empty))
			{
				currentPanelItem.ImageUrl = ItemImageUrl.Replace("*SkinPath*", dnnSkinPath).Replace("*PageName*", pageName);
			}
			if ((ItemHoveredImageUrl != string.Empty))
			{
				currentPanelItem.HoveredImageUrl = ItemHoveredImageUrl.Replace("*SkinPath*", dnnSkinPath).Replace("*PageName*", pageName);
			}
			if ((!ItemHeight.IsEmpty))
			{
				currentPanelItem.Height = ItemHeight;
			}
			if ((!ItemWidth.IsEmpty))
			{
				currentPanelItem.Width = ItemWidth;
			}
		}
		private void SetRootItemProperties(RadPanelItem currentPanelItem, int iLevel, int iItem, string pageName)
		{
			string sLevel = EnableLevelCss && iLevel < MaxLevelNumber ? "Level" + iLevel.ToString() : string.Empty;
			string sItem = iItem <= MaxItemNumber && ((EnableItemCss && iLevel > 0) || (EnableRootItemCss && iLevel == 0)) ? iItem.ToString() : string.Empty;
			if ((RootItemCssClass != string.Empty))
			{
				currentPanelItem.CssClass = sLevel + RootItemCssClass + sItem;
			}
			if ((RootItemDisabledCssClass != string.Empty))
			{
				currentPanelItem.DisabledCssClass = sLevel + RootItemDisabledCssClass + sItem;
			}
			if ((RootItemExpandedCssClass != string.Empty))
			{
				currentPanelItem.ExpandedCssClass = sLevel + RootItemExpandedCssClass + sItem;
			}
			if ((RootItemFocusedCssClass != string.Empty))
			{
				currentPanelItem.FocusedCssClass = sLevel + RootItemFocusedCssClass + sItem;
			}
			if ((RootItemClickedCssClass != string.Empty))
			{
				currentPanelItem.ClickedCssClass = sLevel + RootItemClickedCssClass + sItem;
			}
			if ((RootItemImageUrl != string.Empty))
			{
				currentPanelItem.ImageUrl = RootItemImageUrl.Replace("*SkinPath*", dnnSkinPath).Replace("*PageName*", pageName);
			}
			if ((RootItemHoveredImageUrl != string.Empty))
			{
				currentPanelItem.HoveredImageUrl = RootItemHoveredImageUrl.Replace("*SkinPath*", dnnSkinPath).Replace("*PageName*", pageName);
			}
			if ((!RootItemHeight.IsEmpty))
			{
				currentPanelItem.Height = RootItemHeight;
			}
			if ((!RootItemWidth.IsEmpty))
			{
				currentPanelItem.Width = RootItemWidth;
			}
		}
		private void BuildPanelbar(RadPanelItemCollection rootCollection)
		{
			qElement temp;
			qElement temp2;
			TabInfo page;
			int pageID;
			int j;
			int iItemIndex;
			while (PagesQueue.Count != 0)
			{
				pageID = Convert.ToInt32(PagesQueue.Dequeue());
				temp = (qElement)AuthPages[pageID];
				page = (TabInfo)temp.page;
				temp.radPanelItem.Text = page.TabName;
				if ((!String.IsNullOrEmpty(page.IconFile) && EnablePageIcons))
				{
					if ((page.IconFile.StartsWith("~")))
					{
						temp.radPanelItem.ImageUrl = this.Page.ResolveUrl(page.IconFile);
					}
					else
					{
						temp.radPanelItem.ImageUrl = PortalSettings.HomeDirectory + page.IconFile;
					}
				}
				if ((!page.DisableLink))
				{
					if ((page.FullUrl.StartsWith("*") && page.FullUrl.IndexOf("*", 1) != -1))
					{
						temp.radPanelItem.NavigateUrl = page.FullUrl.Substring(page.FullUrl.IndexOf("*", 1) + 1);
						temp.radPanelItem.Target = page.FullUrl.Substring(1, page.FullUrl.IndexOf("*", 1) - 1);
					}
					else
					{
						temp.radPanelItem.NavigateUrl = page.FullUrl;
					}
				}
				else if ((CopyChildItemLink && page.Level >= MaxLevel))
				{
					j = 0;
					while ((j < AuthPages.Count && (((qElement)AuthPages[j]).page.ParentId != page.TabID || ((qElement)AuthPages[j]).page.DisableLink)))
					{
						j = j + 1;
					}
					if ((j < AuthPages.Count))
					{
						temp.radPanelItem.NavigateUrl = ((qElement)AuthPages[j]).page.FullUrl;
					}
				}
				if ((EnableToolTips && !String.IsNullOrEmpty(page.Description)))
				{
					temp.radPanelItem.ToolTip = page.Description;
				}
				if ((temp.radPanelItem.Level == 0))
				{
					SetRootItemProperties(temp.radPanelItem, page.Level, temp.item, page.TabName);
				}
				else
				{
					SetItemProperties(temp.radPanelItem, page.Level, temp.item, page.TabName);
				}
				if ((ShowPath))
				{
					CheckShowPath(page.TabID, temp.radPanelItem, page.TabName);
				}
				if ((ImagesOnlyPanel && temp.radPanelItem.ImageUrl != string.Empty))
				{
					temp.radPanelItem.Text = string.Empty;
				}
				if ((page.Level < MaxLevel || MaxLevel < 0))
				{
					iItemIndex = 0;
					for (j = 0; j <= AuthPages.Count - 1; j++)
					{
						temp2 = (qElement)AuthPages[j];
						if ((temp2.page.ParentId == page.TabID))
						{
							temp.radPanelItem.Items.Add(temp2.radPanelItem);
							PagesQueue.Enqueue(j);
							iItemIndex = iItemIndex + 1;
							temp2.item = iItemIndex;
							AuthPages[j] = temp2;
						}
					}
				}
			}
		}
	}
}
